﻿/********************************************************************************
** @ Date:2023/11/22
** @ Author: Gaojia
** @ Description: 自定义表格控件B
** @ Version:1.0.0
** @ Fun:
********************************************************************************/
#ifndef CTableWidgetB_H
#define CTableWidgetB_H
#include <qtablewidget.h>
#include <QLabel>
#include <QPushButton>
#include <QHeaderView>
#include <QVector>

class CTableWidgetB :
	public QTableWidget
{
	Q_OBJECT

	/**
	* @ Author: hanjiaxing
	* @ Description: 跑偏记录查询
	*/
	struct MyStructCorrectItem
	{
		QLabel    *     m_pLabIndex;     //序号
		QLabel    *     m_pLabPointName;  //点位名称
		QLabel    *     m_pLabStartTime;  //开始时间
		QLabel    *     m_pLabEndTime; //结束时间
		QLabel    *     m_pLeftValue;  //跑偏左侧值
		QLabel    *     m_pRightValue;  //跑偏右侧值
		QLabel    *     m_pAlarmDesc; //跑偏报警描述
		QLabel    *     m_pBtnImage;  //报警截图
		QPushButton *   m_pBtnView;      //查询明细
		MyStructCorrectItem()
		{
			m_pLabIndex = new QLabel();
			m_pLabPointName = new QLabel();
			m_pLabStartTime = new QLabel();
			m_pLabEndTime = new QLabel();
			m_pLeftValue = new QLabel();
			m_pRightValue = new QLabel();
			m_pAlarmDesc = new QLabel();
			m_pBtnImage = new QLabel();
			m_pBtnView = new QPushButton();

			m_pLabIndex->setAlignment(Qt::AlignCenter);
			m_pLabPointName->setAlignment(Qt::AlignCenter);
			m_pLabStartTime->setAlignment(Qt::AlignCenter);
			m_pLabEndTime->setAlignment(Qt::AlignCenter);
			m_pLeftValue->setAlignment(Qt::AlignCenter);
			m_pRightValue->setAlignment(Qt::AlignCenter);
			m_pAlarmDesc->setAlignment(Qt::AlignCenter);
			m_pBtnImage->setAlignment(Qt::AlignCenter);
			m_pBtnView->setText(QString::fromLocal8Bit("查看明细"));

			/*m_pLabIndex->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabPointName->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabStartTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLabEndTime->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pLeftValue->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pRightValue->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pAlarmDesc->setStyleSheet("background-color: transparent;color: rgb(255, 255, 255);border: none;");
			m_pBtnImage->setStyleSheet("QPushButton:hover { background-color:  rgba(85, 255, 127,150); };background-color: transparent;color: rgb(255, 255, 255);border: none;");*/
		}
	};

	struct MyStructResultItem
	{
		QLabel    *     m_pLabIndex;     //序号
		QLabel    *     m_pResultName;    //报告名
		QLabel    *     m_pReslutTime;  //生成时间
		QLabel    *     m_pPath; //保存路径
		QPushButton*    m_pBtnView;	   //查看

		MyStructResultItem()
		{
			m_pLabIndex = new QLabel();
			m_pResultName = new QLabel();
			m_pReslutTime = new QLabel();
			m_pPath = new QLabel();
			m_pBtnView = new QPushButton();

			m_pLabIndex->setAlignment(Qt::AlignCenter);
			m_pResultName->setAlignment(Qt::AlignCenter);
			m_pReslutTime->setAlignment(Qt::AlignCenter);
			m_pPath->setAlignment(Qt::AlignCenter);
			m_pBtnView->setText(QString::fromLocal8Bit("查看"));

			m_pLabIndex->setStyleSheet("background-color: transparent;color: rgb(0, 0, 0);border: none;outline: none;");
			m_pLabIndex->setFocusPolicy(Qt::NoFocus); // 禁用焦点
			m_pLabIndex->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
			m_pResultName->setStyleSheet("background-color: transparent;color: rgb(0, 0, 0);border: none;outline: none;");
			m_pResultName->setFocusPolicy(Qt::NoFocus); // 禁用焦点
			m_pResultName->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
			m_pReslutTime->setStyleSheet("background-color: transparent;color: rgb(0, 0, 0);border: none;outline: none;");
			m_pReslutTime->setFocusPolicy(Qt::NoFocus); // 禁用焦点
			m_pReslutTime->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
			m_pPath->setStyleSheet("background-color: transparent;color: rgb(0, 0, 0);border: none;outline: none;");
			m_pPath->setFocusPolicy(Qt::NoFocus); // 禁用焦点
			m_pPath->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
			m_pBtnView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
		}
	};

public:
	CTableWidgetB(QWidget *parent);
	~CTableWidgetB();
	void InitUi(int nType);//初始化界面
	void InitData(int nType, QVector<QVector<QString>>vecStr);          //表格类型
	QVector<QVector<QString>>m_vecvStr;
	int m_nDataType;//表格类型  0任务  1巡检点 2巡检项 3AI算法报警结果查询界面 4皮带跑偏结果查询
	QString m_sPageUuid;
public slots:
	void slotClickedShowImg();//展示图片
	void onImageDownloaded(QLabel* pLabel,QPixmap pixmap,QString sPageUuid);
	void slotClickedShowResult();//查询报告对话框

signals:
	void sigShowImg(QString sHttpUrl);
	void sigShowResult(QString sPath);
};

#endif